package cn.udinghuo.model.archives.bank;

import java.util.HashMap;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import cn.udinghuo.core.value.Enumable;
/**
 * @author ssk
 *	银行分类
 */
public enum BankCategory implements Enumable {

	
	/**
     * 国有银行
     */
	COUNTRYOWNEDBANK("国有银行" ,(short)1),
	/**
     * 股份制银行
     */
	JOINTSTOCKBANK("股份制银行" ,(short)2),
	/**
     * 城镇银行
     */
	TOWNBANK("城镇银行" ,(short)3),
	/**
     * 政策性银行
     */
	POLICYBANK("政策性银行" ,(short)4),
	/**
     * 外资银行
     */
	FOREIGNBANK("外资银行" ,(short)5);
	
	private String title;
	private short value;
	
	BankCategory(String title,short value){
		this.title=title;
		this.value=value;
	}

	
	@JsonValue
	@Override
	public Short getValue(){
		return this.value;
	}
	
	@Override
	public String getName(){
		return this.name();
	}
	
	@Override
	public String getTitle(){
		return this.title;
	}
	
	private static HashMap<Integer, BankCategory> map = null;
	
	private synchronized static void initMap() {
		if (map != null) {
			return;
		}
		map = new HashMap<Integer, BankCategory>();
		BankCategory[] items = BankCategory.values();
		for (BankCategory item : items) {
			map.put(item.getValue().intValue(), item);
		}
	}
	@JsonCreator
	public static BankCategory find(Integer value) {
		if (value == null) {
			return null;
		}
		if (map == null) {
			initMap();
		}
		return map.get(value);
	}
}

